<?php

/**
 *
 *  PayAction.class.php (支付模块)
 * 
 */
class PayAction extends Action {

//    function _initialize() {
//        parent::_initialize();
//        if (!$this->_userid) {
//            //$this->assign('jumpUrl',U('User/Login/index'));
//            //$this->error(L('nologin'));
//        }
//        $this->dao = M('User');
//        $this->assign('bcid', 0);
//        $user = $this->dao->find($this->_userid);
//        $this->assign('vo', $user);
//    }

    public function index() {
        $this->display();
    }

    public function Recharge() {
        $this->display();
    }

    public function pay() {
        $this->display();
    }

    public function respond() {
        $pay_code = !empty($_REQUEST['code']) ? t($_REQUEST['code']) : '';
        $pay_code = ucfirst($pay_code);
        $Payment  = M('Payment')->where(array('pay_code'     => $pay_code))->find();
        if (empty($Payment))
            $this->error('回调地址有误');
        $aliapy_config = unserialize($Payment['pay_config']);
        import("Think.ORG.Pay." . $pay_code);
        $pay           = new $pay_code($aliapy_config);
        $r             = $pay->respond();
        $this->assign('jumpUrl', U('User/Pay/index'));
        if ($r) {
            $this->error('支付成功');
        } else {
            $this->error('支付失败');
        }
    }

}

?>